package com.solarStruggle.actions

import java.awt.event.{InputEvent, KeyEvent}
import javax.swing.{ImageIcon, KeyStroke}
import scala.swing.{Action}
import controls.{GuiState, ZoomLevelChanged}
import util.{ResourceLoader}

/**
 * Action used to increase the zoom level of the main screen.
 */
class ZoomInAction(state: GuiState) 
extends Action("Zoom In") {
  
  enabled = true
  
  toolTip = "Increase the size of the main screen's elements"

  accelerator = Some(KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, InputEvent.CTRL_DOWN_MASK))
  icon = new ImageIcon(ResourceLoader.getResourceURL("img/actions/zoom-in.png"))
  smallIcon = new ImageIcon(ResourceLoader.getResourceURL("img/actions/zoom-in-small.png"))
  
  def apply() {
    if(state.zoomLevel < state.maxZoomLevel)
      state.zoomLevel += 1
  }
  
  state.reactions += {
    case ZoomLevelChanged(newLevel) => enabled = newLevel < state.maxZoomLevel
  }
    
}
